package com.supermap.originTest2;

import com.supermap.data.*;
import com.supermap.data.topology.TopologyProcessing;
import com.supermap.data.topology.TopologyProcessingOptions;

public class TestTopo {


    public static void main(String[] args) {

        GeoPicture geoPicture;
//        geoPicture.setWidth();

        Workspace workspace = new Workspace();

        DatasourceConnectionInfo datasourceConnectionInfo = new DatasourceConnectionInfo();
        datasourceConnectionInfo.setDatabase("test0322");
        datasourceConnectionInfo.setEngineType(EngineType.PGGIS);
        datasourceConnectionInfo.setServer("localhost");
        datasourceConnectionInfo.setPassword("123456");
        datasourceConnectionInfo.setUser("postgres");

        Datasource datasource = workspace.getDatasources().open(datasourceConnectionInfo);
        if (datasource == null) {
            System.out.println("打开数据源失败");
            return;
        } else {
            System.out.println("数据源打开成功！");
        }

        DatasetVector datasetVector = (DatasetVector) datasource.getDatasets().get("Railway_L");

        TopologyProcessingOptions options = new TopologyProcessingOptions();
        options.setLinesIntersected(false);
        options.setOvershootsCleaned(false);
        options.setUndershootsExtended(true);
        options.setAdjacentEndpointsMerged(false);
        options.setRedundantVerticesCleaned(false);
        options.setDuplicatedLinesCleaned(false);
        options.setPseudoNodesCleaned(false);
        options.setOvershootsTolerance(0.1d);
        options.setUndershootsTolerance(0.1d);
        options.setVertexTolerance(0.001d);
        boolean result = TopologyProcessing.clean(datasetVector, options);
        System.out.println(result);
    }

}
